package com.tan.controller;


import com.tan.model.AirQualityIndex;
import com.tan.model.District;
import com.tan.service.DistrictService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class TestController {

    @Resource
    DistrictService ds;

    @RequestMapping("/")
    public ModelAndView toTest(ModelAndView mav){
        mav.setViewName("/test");
        List<District> allDistrict = ds.getAllDistrict();
        mav.addObject("districtList",allDistrict);
        System.out.println(allDistrict);
        return mav;
    }

    @PostMapping("/result")
    @ResponseBody
    public String show(AirQualityIndex airQualityIndex){
        return airQualityIndex.toString();
    }
}
